#include <iostream>

using namespace std;

int min(int a , int b){
    if (a > b)
        return b;
    else
        return a;
}
int find (int* nums1, int m, int* nums2, int n, int k){
    if (m > n)
        return find(nums2,n,nums1,m,k);
//    printf("%d %d\n",m,n);
    if (m == 0){
        return nums2[k-1];
    }
    if (k == 1)
        return min(nums1[0],nums2[0]);
    int pa = min(k/2,m);
    int pb = k - pa;
    if (nums1[pa-1] < nums2[pb-1]){
        return find(nums1 + pa , m - pa , nums2, n , k - pa );
    }else if (nums1[pa - 1] > nums2[pb - -1])
        return find(nums1 , m , nums2 + pb , n - pb ,k - pb );
    else
        return nums1[pa-1];
}
double findMedianSortedArrays(int* nums1, int nums1Size, int* nums2, int nums2Size) {
    int total = nums1Size + nums2Size ;
    if (total %2 == 1){
        return find(nums1,nums1Size,nums2,nums2Size,total/2+1);
    }else
        return (find(nums1,nums1Size,nums2,nums2Size,total/2)+find(nums1,nums1Size,nums2,nums2Size,total/2+1))/2.0;
}

int main() {
    int nums1[] = {1,2,2};
    int nums2[] = {1,2,3};
    printf("%lf\n",findMedianSortedArrays(nums1, 3, nums2, 3));
}